/**
 * Created by Alice on 2016/9/19 0019
 */

$(function () {
    $("#sys_court_status").find("a").attr("href", r.base_path + "system_monitor/sys_court_status?courtUid=" + r.court_uid);
    $("#sys_play_info").find("a").attr("href", r.base_path + "system_monitor/sys_play_info?court=Uid" + r.court_uid);
    $("#sys_fault_condition").find("a").attr("href", r.base_path + "views/system_monitor/sys_fault_condition.html?court=" + r.court_id);
    $("#sys_meeting").find("a").attr("href", r.base_path + "views/system_monitor/sys_meeting.html?court=" + r.court_id);
    $("#sys_server_status").find("a").attr("href", r.base_path + "system_monitor/sys_server_status?courtUid=" + r.court_uid);
    $("#sys_equipment_management").find("a").attr("href", r.base_path + "views/system_monitor/sys_equipment_management.html?court=" + r.court_id);
    $("#sys_log_info").find("a").attr("href", r.base_path + "system_monitor/sys_log_info?courtUid=" + r.court_uid);
    getUserList();
    getPlayList();
});

function getUserList() {
    $.get(r.base_path + "getUserList", function (result) {
        if (result && result.status == 0) {
            var n = 1;
            $("#userList").find("tbody").empty();
            for (var i in result) {
                var re = JSON.parse(result[i]);
                var str = "<tr><td>" + n + "</td><td>" + re["username"] + "</td><td>" + re.caseno + "</td></tr>";
                $("#userList").find("tbody").append(str);
                n = n + 1;
            }
        } else {
            $('#userList').parent('div').html('<span>暂时没有人正在点播案件.</span>');
        }

    }).fail(function () {
        $('#userList').parent('div').html('<span>连接服务器异常</span>');
    }, 'json');
    $("#userList").show();
    $("#loading").hide();
}

function getPlayList() {
    $.get(r.base_path + "playInfo/getPlayList", function (result) {
        if (result && result.data && result.data.length > 0) {
            $("#playList").find("tbody").empty();

            $.each(result.data, function (n, ele) {
                var str = "<tr><td>" + (n + 1) + "</td><td>" + ele.realName + "</td><td>" + ele.caseNo + "</td>";
                if ("1" == ele.type) {
                    str += "<td>直播</td></tr>";
                } else {
                    str += "<td>点播</td></tr>";
                }
                $("#playList").find("tbody").append(str);

            });

        } else {
            $('#playList').parent('div').html('<span>暂时没有人正在点播案件.</span>');
        }

    }).fail(function () {
        $('#playList').parent('div').html('<span>连接服务器异常</span>');
    }, 'json');
    $("#playList").show();
    $("#loading").hide();
}
